home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / mus / play / tracker_4_31.lzh / tracker / analyzer.c next >
C/C++ Source or Header  |  1995-05-15  |  3KB  |  177 lines

  1. /* analyzer.c 
  2.     vi:ts=3 sw=3:
  3. */
  4.  
  5.  
  6. /* read module files and output statistics on them */
  7.  
  8. /* $Id: analyzer.c,v 4.20 1995/05/15 12:19:43 espie Exp espie $
  9.  * $Log: analyzer.c,v $
  10.  * Revision 4.20  1995/05/15  12:19:43  espie
  11.  * *** empty log message ***
  12.  *
  13.  * Revision 4.19  1995/05/12  13:53:04  espie
  14.  * New synchronization.
  15.  *
  16.  * Revision 4.18  1995/02/21  17:54:32  espie
  17.  * Internal problem: buggy RCS. Fixed logs.
  18.  *
  19.  * Revision 4.13  1995/02/20  22:28:50  espie
  20.  * Spurious bug with # of samples.
  21.  *
  22.  * Revision 4.12  1995/02/20  16:49:58  espie
  23.  * Working.
  24.  *
  25.  * Revision 4.9  1995/02/06  14:50:47  espie
  26.  * Changed sample_info.
  27.  *
  28.  * Revision 4.7  1995/02/01  16:39:04  espie
  29.  * Includes moved to defs.h
  30.  *
  31.  * Revision 4.6  1995/01/28  09:23:59  espie
  32.  * Need (?) a return 0 at the end.
  33.  *
  34.  * Revision 4.1  1994/01/12  16:10:20  espie
  35.  * Fixed up last minute problems.
  36.  * Lots of changes.
  37.  * removed create_note_tables(), run_in_fg().
  38.  * Use new pref scheme.
  39.  * New open_file semantics.
  40.  * Added speed check.
  41.  * Added patch for non termio.
  42.  */
  43.  
  44. #include "defs.h"
  45.  
  46. #include "extern.h"
  47. #include "song.h"
  48. #include "tags.h"
  49. #include "prefs.h"
  50.  
  51. ID("$Id: analyzer.c,v 4.20 1995/05/15 12:19:43 espie Exp espie $")
  52.  
  53. int error;
  54.  
  55.  
  56. int use_command[16];
  57. int use_extended[16];
  58.  
  59. void analyze_block(b)
  60. struct block *b;
  61.    {
  62.    int i, j;
  63.    struct event *e;
  64.  
  65.    for (i = 0; i < BLOCK_LENGTH; i++)
  66.       {
  67.       int special;
  68.  
  69.       special = 0;
  70.       for (j = 0; j < NUMBER_TRACKS; j++)
  71.          {
  72.          e = &b->e[j][i];
  73.          switch(e->effect)
  74.             {
  75. #if 0
  76.          case 13: /* skip */
  77.             return;
  78.          case 11: /* fastskip */
  79.             return;
  80. #endif
  81.          case 14:
  82.                 if (!use_extended[HI(e->parameters)])
  83.                     use_extended[HI(e->parameters)] = i+1;
  84.             break;
  85.          case 15:
  86.             if (special != 0 && e->parameters != special)
  87.                putchar('!');
  88.             else
  89.                special = e->parameters;
  90.          default:
  91.                 if (!use_command[e->effect])
  92.             use_command[e->effect] = i+1;
  93.             }
  94.          }
  95.       }
  96.    }
  97.  
  98.  
  99. void analyze_song(song)
  100. struct song *song;
  101.    {
  102.    int i;
  103.  
  104.    for (i = 1; i <= song->ninstr ; i++)
  105.       {
  106.       if (song->samples[i])
  107.          {
  108.          if (song->samples[i]->finetune)
  109.             printf("Sample %d: finetune is %d\n", 
  110.                i, song->samples[i]->finetune);
  111.          }
  112.       }
  113.    for (i = 0; i < 16; i++)
  114.       {
  115.       use_command[i] = FALSE;
  116.       use_extended[i] = FALSE;
  117.       }
  118.    for (i = 0; i < song->info.maxpat; i++)
  119.       analyze_block(song->info.pblocks+i);
  120.    for (i = 0; i < 16; i++)
  121.       if (use_command[i])
  122.          printf("%3d", i);
  123.    for (i = 0; i < 16; i++)
  124.       if (use_extended[i])
  125.          printf("%3dE", i);
  126.    printf("\n");
  127.    }
  128.  
  129. int main(argc, argv)
  130. int argc;
  131. char **argv;
  132.    {
  133.    int i;
  134.  
  135.     struct exfile *file;
  136.    struct song *song;
  137.    int default_type;
  138.  
  139.    default_type = BOTH;
  140.    set_pref_scalar(PREF_TOLERATE, 2);
  141.  
  142.    for (i = 1; i < argc; i++)
  143.       {
  144.         file = open_file(argv[i], "r", getenv("MODPATH"));
  145.         if (file)
  146.             {
  147.             song = read_song(file, NEW);
  148.             if (!song)
  149.                 {
  150.                 rewind_file(file);
  151.                 song = read_song(file, OLD);
  152.                 }
  153.             close_file(file);
  154.             if (song)
  155.                 {
  156.                 puts(argv[i]);
  157.                 analyze_song(song);
  158.                 release_song(song);
  159.                 }
  160.             }
  161.       }
  162.    return 0;
  163.    }
  164.  
  165.  
  166. void sync_audio(f, p)
  167. void (*f) P((GENERIC));
  168. GENERIC p;
  169.     {
  170.     }
  171.  
  172. void audio_ui(c)
  173. int c;
  174.     {
  175.     }
  176.  
  177.